//
//  ChooseTimeView.m
//  Runone
//
//  Created by ekkaLyn on 2017/3/14.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "ChooseTimeView.h"
#import "SDAutoLayout.h"

@interface ChooseTimeView ()

@property (nonatomic, copy) NSString *leftTitleStr; //左边标题

@end

@implementation ChooseTimeView

- (ChooseTimeView *) initWithDefalutHeight:(CGFloat) height title:(NSString *)titleStr{
    _leftTitleStr = titleStr;
    return [self initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, height)];
}

//施工事件上报
-(instancetype)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor colorWithRed:226.0 / 255 green:230.0 / 255 blue:240.0 / 255 alpha:1]];
        
        [self configUI];
        [self layoutUI];
    }
    return self;
}

- (void) configUI {
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:15];
    _titleLabel.textAlignment = NSTextAlignmentRight;
    _titleLabel.text = _leftTitleStr;
    
    _timeChooseBtn = [[UIButton alloc] init];
    _timeChooseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _timeChooseBtn.backgroundColor = [UIColor whiteColor];
//    _timeChooseBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -80, 0, 0);
    [_timeChooseBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    _lineView   = [UIView new];
    _lineView.backgroundColor = [UIColor whiteColor];
    [self sd_addSubviews:@[self.titleLabel, self.timeChooseBtn,self.lineView]];
}

- (void) layoutUI {
    self.titleLabel.sd_layout
    .leftSpaceToView(self, 0)
    .topSpaceToView(self, 8)
    .heightIs(34)
    .widthIs(110)
    ;
    
    self.timeChooseBtn.sd_layout
    .leftSpaceToView(self.titleLabel, 8)
    .rightSpaceToView(self, 8)
    .topEqualToView(self.titleLabel)
    .heightIs(34);
    ;
    
    self.lineView.sd_layout
    .leftSpaceToView(self, 8)
    .rightSpaceToView(self, 8)
    .heightIs(1)
    .topSpaceToView(self.titleLabel, 7)
    ;
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:0];
}

- (void) setTimeString:(NSString *)timeStr  {
    [self.timeChooseBtn setTitle:timeStr forState:UIControlStateNormal];
}


@end
